package com.java.simple.study.tool;

import java.util.Objects;

/**
 * @author zhoujl
 * @date 2022/1/9 13:58
 * @desc
 */
public class Singleton {

    /**
     * 禁用指令重排
     */
    private static volatile Singleton INSTANCE = null;

    private Singleton() {
    }

    public static Singleton getInstance() {
        if (Objects.isNull(INSTANCE)) {
            synchronized (Singleton.class) {
                if (Objects.isNull(INSTANCE)) {
                    INSTANCE = new Singleton();
                }
            }
        }
        return INSTANCE;
    }

}
